package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

/**
 * @author zhangxiaorui
 * @ClassName SalesOrgTypeEnum
 * @description: TODO
 * @date 2023/06/12 17:48
 * @version: 1.0
 */
@Getter
public enum SalesOrgTypeEnum {

    ROOT("1", "集团根组织"),
    DIVISION("2", "事业部"),
    SALES_REGION("3", "销售大区"),
    BUSINESS_UNIT("4", "分子公司/RBU/CBU"),
    SUB_COMPANY("5", "分子公司"),
    SALES_ORG("6", "销售组织"),
    FIRST_LEVEL("7", "自定义一级组织"),
    SECOND_LEVEL("8", "自定义二级组织"),
    THIRD_LEVEL("9", "自定义三级组织"),
    FOURTH_LEVEL("10", "自定义四级组织");

    private String code;
    private String name;

    SalesOrgTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SalesOrgTypeEnum getByCode(String code) {
        for (SalesOrgTypeEnum orgTypeEnum : values()) {
            if (orgTypeEnum.getCode().equals(code)) {
                return orgTypeEnum;
            }
        }
        return null;
    }

    public static String getNameByCode(String code) {
        for (SalesOrgTypeEnum orgTypeEnum : values()) {
            if (orgTypeEnum.getCode().equals(code)) {
                return orgTypeEnum.getName();
            }
        }
        return null;
    }

    public static SalesOrgTypeEnum getNextTypeByCode(String code) {
        SalesOrgTypeEnum orgTypeEnum = getByCode(code + 1);
        return orgTypeEnum;
    }
}
